home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / library / form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-11-09  |  13.9 KB  |  390 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "VB Library Routines"
  4.    ClientHeight    =   5475
  5.    ClientLeft      =   1455
  6.    ClientTop       =   2250
  7.    ClientWidth     =   6015
  8.    Height          =   6165
  9.    Left            =   1395
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   5475
  12.    ScaleWidth      =   6015
  13.    Top             =   1620
  14.    Width           =   6135
  15.    Begin CommandButton Command1 
  16.       Caption         =   "click to change to lower case"
  17.       Height          =   375
  18.       Left            =   2940
  19.       TabIndex        =   4
  20.       Top             =   4980
  21.       Width           =   3015
  22.    End
  23.    Begin ListBox List1 
  24.       Height          =   1200
  25.       Left            =   2940
  26.       TabIndex        =   3
  27.       Top             =   3720
  28.       Width           =   3015
  29.    End
  30.    Begin TextBox Text2 
  31.       Height          =   1575
  32.       Left            =   3480
  33.       MultiLine       =   -1  'True
  34.       ScrollBars      =   2  'Vertical
  35.       TabIndex        =   2
  36.       Text            =   "This is a sample text box that contains more than one line of text to be used in the Edit Menu and Highlight samples provided."
  37.       Top             =   2100
  38.       Width           =   2475
  39.    End
  40.    Begin TextBox Text1 
  41.       Height          =   1575
  42.       Left            =   3480
  43.       MultiLine       =   -1  'True
  44.       ScrollBars      =   2  'Vertical
  45.       TabIndex        =   1
  46.       Text            =   "This is a sample text box that contains more than one line of text to be used in the Make Text Box Read-only sample provided."
  47.       Top             =   480
  48.       Width           =   2475
  49.    End
  50.    Begin Label Label1 
  51.       Caption         =   "Label1"
  52.       Height          =   255
  53.       Left            =   3480
  54.       TabIndex        =   0
  55.       Top             =   120
  56.       Width           =   2415
  57.    End
  58.    Begin Menu mnuFileMenu 
  59.       Caption         =   "&File"
  60.       Begin Menu mnuFile 
  61.          Caption         =   "&About"
  62.          Index           =   0
  63.       End
  64.       Begin Menu mnuFile 
  65.          Caption         =   "E&xit"
  66.          Index           =   1
  67.       End
  68.    End
  69.    Begin Menu mnuEditMenu 
  70.       Caption         =   "&Edit"
  71.       Begin Menu mnuEdit 
  72.          Caption         =   "Undo"
  73.          Index           =   0
  74.       End
  75.       Begin Menu mnuEdit 
  76.          Caption         =   "Cu&t"
  77.          Index           =   1
  78.       End
  79.       Begin Menu mnuEdit 
  80.          Caption         =   "&Copy"
  81.          Index           =   2
  82.       End
  83.       Begin Menu mnuEdit 
  84.          Caption         =   "&Paste"
  85.          Index           =   3
  86.       End
  87.    End
  88.    Begin Menu mnuSamplesMenu 
  89.       Caption         =   "Samples (&A-L)"
  90.       Begin Menu mnuSamples 
  91.          Caption         =   "Always on top"
  92.          Index           =   0
  93.       End
  94.       Begin Menu mnuSamples 
  95.          Caption         =   "Another Instance (detecting)"
  96.          Index           =   1
  97.       End
  98.       Begin Menu mnuSamples 
  99.          Caption         =   "Center Form"
  100.          Index           =   2
  101.       End
  102.       Begin Menu mnuSamples 
  103.          Caption         =   "Create Path"
  104.          Index           =   3
  105.       End
  106.       Begin Menu mnuSamples 
  107.          Caption         =   "Create Program Manager Group"
  108.          Index           =   4
  109.       End
  110.       Begin Menu mnuSamples 
  111.          Caption         =   "Create Program Manager Item"
  112.          Index           =   5
  113.       End
  114.       Begin Menu mnuSamples 
  115.          Caption         =   "Floating Window"
  116.          Index           =   6
  117.       End
  118.       Begin Menu mnuSamples 
  119.          Caption         =   "FreeDrive"
  120.          Index           =   7
  121.       End
  122.       Begin Menu mnuSamples 
  123.          Caption         =   "Get Windows Version"
  124.          Index           =   8
  125.       End
  126.       Begin Menu mnuSamples 
  127.          Caption         =   "Get Windows\System Directory"
  128.          Index           =   9
  129.       End
  130.       Begin Menu mnuSamples 
  131.          Caption         =   "Get Windows Directory"
  132.          Index           =   10
  133.       End
  134.       Begin Menu mnuSamples 
  135.          Caption         =   "Help Click"
  136.          Index           =   11
  137.       End
  138.       Begin Menu mnuSamples 
  139.          Caption         =   "Hide MDI Child Form"
  140.          Index           =   12
  141.       End
  142.       Begin Menu mnuSamples 
  143.          Caption         =   "Highlight Textbox Text"
  144.          Index           =   13
  145.       End
  146.       Begin Menu mnuSamples 
  147.          Caption         =   "If File Exists"
  148.          Index           =   14
  149.       End
  150.       Begin Menu mnuSamples 
  151.          Caption         =   "Is Path Valid"
  152.          Index           =   15
  153.       End
  154.       Begin Menu mnuSamples 
  155.          Caption         =   "Locate Pointer"
  156.          Index           =   16
  157.       End
  158.    End
  159.    Begin Menu mnuSamples2Menu 
  160.       Caption         =   "Samples (&M-Z)"
  161.       Begin Menu mnuSamples2 
  162.          Caption         =   "Make Read-Only (textbox)"
  163.          Index           =   0
  164.       End
  165.       Begin Menu mnuSamples2 
  166.          Caption         =   "Menu (Edit) Shortcuts"
  167.          Index           =   1
  168.       End
  169.       Begin Menu mnuSamples2 
  170.          Caption         =   "Move Form without a titlebar"
  171.          Index           =   2
  172.       End
  173.       Begin Menu mnuSamples2 
  174.          Caption         =   "Paint Form (multi-colored) (no API)"
  175.          Index           =   3
  176.       End
  177.       Begin Menu mnuSamples2 
  178.          Caption         =   "Purge Numeric Input"
  179.          Index           =   4
  180.       End
  181.       Begin Menu mnuSamples2 
  182.          Caption         =   "Purge String (removing characters)"
  183.          Index           =   5
  184.       End
  185.       Begin Menu mnuSamples2 
  186.          Caption         =   "Read File Chunk"
  187.          Index           =   6
  188.       End
  189.       Begin Menu mnuSamples2 
  190.          Caption         =   "Reboot Computer"
  191.          Index           =   7
  192.       End
  193.       Begin Menu mnuSamples2 
  194.          Caption         =   "Resource Monitor"
  195.          Index           =   8
  196.       End
  197.       Begin Menu mnuSamples2 
  198.          Caption         =   "Restart Windows"
  199.          Index           =   9
  200.       End
  201.       Begin Menu mnuSamples2 
  202.          Caption         =   "Select Item in a listbox"
  203.          Index           =   10
  204.       End
  205.       Begin Menu mnuSamples2 
  206.          Caption         =   "UpEach make 1st letter of each word Cap"
  207.          Index           =   11
  208.       End
  209.       Begin Menu mnuSamples2 
  210.          Caption         =   "UpFirst -Capitalize 1st letter in string"
  211.          Index           =   12
  212.       End
  213.    End
  214.    Begin Menu mnuHelpMenu 
  215.       Caption         =   "&Help"
  216.       Begin Menu mnuHelp 
  217.          Caption         =   "Contents"
  218.          Index           =   0
  219.       End
  220.       Begin Menu mnuHelp 
  221.          Caption         =   "Search"
  222.          Index           =   1
  223.       End
  224.       Begin Menu mnuHelp 
  225.          Caption         =   "Help on Help"
  226.          Index           =   2
  227.       End
  228.    End
  229. Option Explicit
  230. Sub Command1_Click ()
  231.     Command1.Caption = LCase(Command1.Caption)
  232. End Sub
  233. Sub Form_Load ()
  234.     Dim x As Integer
  235.     Show
  236.     form2.Show
  237.     For x = 1 To 26
  238.         list1.AddItem String$(10, x + 64)
  239.     Next x
  240. End Sub
  241. Sub Form_MouseDown (Button As Integer, Shift As Integer, x As Single, Y As Single)
  242. '   Move Forms Without Title Bars
  243. '   This example was posted on the internet and shows a way that a form without a title bar can be moved around by the user with a mouse.
  244.     If Button = 1 Then  ' Checking for Left Button only
  245.        Dim ReturnVal%
  246.        ReleaseCapture
  247.        ReturnVal% = SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
  248.     End If
  249. End Sub
  250. Sub mnuEdit_Click (Index As Integer)
  251. '   This routine is designed for a quick & dirty method for handling
  252. '   common edit menu functions.
  253.     Select Case Index
  254.         Case 0: SendKeys "%{BACKSPACE}"     ' Undo
  255.         Case 1: SendKeys "+{DELETE}"        ' Cut
  256.         Case 2: SendKeys "^{INSERT}"        ' Copy
  257.         Case 3: SendKeys "+{INSERT}"        ' Paste
  258.     End Select
  259. End Sub
  260. Sub mnuFile_Click (Index As Integer)
  261.     Dim MsgBoxText As String
  262.     Select Case Index
  263.         Case 0
  264.             MsgBoxText = "VB Library Routines" + Chr(13) + Chr(10)
  265.             MsgBoxText = MsgBoxText + "Uploaded by JSHARGETT" + Chr(13) + Chr(10)
  266.             MsgBoxText = MsgBoxText + "Placed into the public domain" + Chr(13) + Chr(10)
  267.             MsgBoxText = MsgBoxText + "Enjoy!" + Chr(13) + Chr(10)
  268.             MsgBox MsgBoxText
  269.         Case 1
  270.             Unload form2
  271.             End
  272.     End Select
  273. End Sub
  274. Sub mnuSamples_Click (Index As Integer)
  275.     Dim x As Integer
  276.     Dim T As String
  277.     Select Case Index
  278.         Case 0: 'Always on top
  279.             x = MsgBox("Do you want to make this Program" & Chr$(13) & Chr$(10) & "Always on Top?", 36, "Always On Top Sample")
  280.             If x = 6 Then
  281.                AlwaysOnTop Me, True
  282.             Else
  283.                AlwaysOnTop Me, False
  284.             End If
  285.         Case 1: 'Another instance (detecting)
  286.             If AnotherInstance() Then End
  287.         Case 2: 'Center Form
  288.             CenterForm Me
  289.         Case 3: 'Create Path
  290.             T = InputBox("Enter the path you would like to create (including Drive)")
  291.             x = CreatePath(T)
  292.             If x Then MsgBox "The path " + T + " was created successfully"
  293.         Case 4: 'Create Program Manager Group
  294.             CreateProgManGroup Me, "VB Library", GetWindowsDir()
  295.         Case 5: 'Create Program Manager Item (icon)
  296.             CreateProgManItem Me, app.Path + "\library", "VB Library"
  297.         Case 6: 'Floating Window
  298.             MsgBox "Minimize this window and watch the small one go with it!"
  299.             FloatingWindow (form2.hWnd), (Me.hWnd)
  300.         Case 7: 'FreeDrive
  301.             MsgBox "Next available drive letter is " + FreeDrive()
  302.         Case 8: 'Get Version
  303.             T = GetWindowsVersion()
  304.             MsgBox T, 48, "Current Windows Version"
  305.         Case 9: 'Get Windows\System directory
  306.             MsgBox GetSystemDir(), 48, "Windows\System Directory"
  307.         Case 10: 'Get Windows directory
  308.             MsgBox GetWindowsDir(), 48, "Windows Directory"
  309.         Case 11: 'Help Click
  310.             Help_Click "Filename.Hlp", Me
  311.         Case 12: 'Hide MDI Child Form
  312.             MDIParent.Show
  313.             MsgBox "This routine will hide Child Window #2", 48, "VB Library"
  314.             HideMDIChild MDIChild2
  315.         Case 13: 'Highlight Textbox Text
  316.             Text2.SetFocus
  317.             HighlightText
  318.         Case 14: 'If File Exists
  319.             T = InputBox("Enter a filename to check the existance of (including Drive & path)")
  320.             x = IfFileExists(T)
  321.             If x Then
  322.                 MsgBox "The file exists", 48, "VB Library"
  323.             Else
  324.                 MsgBox "The file does not exist or is hidden", 48, "VB Library"
  325.             End If
  326.         Case 15: 'Is Path Valid
  327.             T = InputBox("Enter a pathname to check the validity of (including Drive)")
  328.             x = IsPathValid(T, Left$(T, 2))
  329.             If x Then
  330.                 MsgBox "The path is valid", 48, "VB Library"
  331.             Else
  332.                 MsgBox "The path is NOT valid", 48, "VB Library"
  333.             End If
  334.         Case 16: 'Locate Pointer
  335.             Dim Pnt As PointAPI
  336.             GetCursorPos Pnt
  337.             MsgBox "Cursor is located at " + Str$(Pnt.x) + "," + Str$(Pnt.Y), 48, "VB Library"
  338.     End Select
  339. End Sub
  340. Sub mnuSamples2_Click (Index As Integer)
  341.     Dim x As Integer
  342.     Dim T As String
  343.     Dim T2 As String
  344.     Select Case Index
  345.         Case 0: 'Make Read-Only Textbox
  346.             MakeReadOnly (text1.hWnd)
  347.         Case 1: 'Menu (edit) shortcuts
  348.             MsgBox "See Edit Menu for demonstrations"
  349.         Case 2: 'Move form without a titlebar
  350.             MsgBox "Click on a blank area of this form and drag"
  351.         Case 3: 'Paint Form without API
  352.             PaintForm Me, 1, 100, 0, 255, 1, 0, -1
  353.         Case 4: 'Purge Numeric Input
  354.             T = InputBox("Enter numbers and text here")
  355.             MsgBox PurgeNumericInput(T)
  356.         Case 5: 'Purge String (removing characters)
  357.             T = InputBox("Enter a string of text here")
  358.             T2 = InputBox("Enter a substring of text to remove")
  359.             MsgBox PurgeString(T2, T)
  360.         Case 6: 'Read File Chunk
  361.             MsgBox "This routine will read and display your C:\AUTOEXEC.BAT file", 48, "VB Library"
  362.             Me.Cls
  363.             T = ReadFileChunk("C:\autoexec.bat", 0)
  364.             Do
  365.                 Me.Print T '(or whatever you want to do with the file)
  366.                 If Len(T) < 1000 Then Exit Do              ' Reached EOF yet?
  367.                 T = ReadFileChunk("C:\autoexec.bat", 1)    ' Continue reading
  368.             Loop
  369.         Case 7: 'Reboot Computer
  370.             If MsgBox("This routine will Reboot your computer." & Chr$(13) & Chr$(10) & "Are you sure you want to do this now?", 36, "Reboot System?") = 6 Then
  371.                 x = RebootSystem()
  372.                 If Not x Then MsgBox "Some program(s) refused to terminate", 48, "VB Library"
  373.             End If
  374.         Case 8: 'Resource Monitor
  375.             ResourceMonitor
  376.         Case 9: 'Restart Windows
  377.             If MsgBox("This routine will Restart Windows." & Chr$(13) & Chr$(10) & "Are you sure you want to do this now?", 36, "Restart Windows?") = 6 Then
  378.                 x = RestartWindows()
  379.                 If Not x Then MsgBox "Some program(s) refused to terminate", 48, "VB Library"
  380.             End If
  381.         Case 10: 'Select Item in a listbox
  382.             T = InputBox("Enter a substring of one of the lines in the listbox")
  383.             SelectListItem list1, T
  384.         Case 11: 'UpEach (Capitalizing first letter of each word)
  385.             Command1.Caption = Upeach((Command1.Caption))
  386.         Case 12: 'UpFirst (Capitalizing first letter of string)
  387.             Command1.Caption = UpFirst((Command1.Caption))
  388.     End Select
  389. End Sub
  390.